#include <stdio.h>
#include <stdlib.h>     
#include "create_linked_list.h"
#include "../common/func.h"

//创建节点并插入链表是从后往前插入
void CreateList_L (LinkList & L, int n){
    // 逆位序输入 n 个元素的值，建立带表头结点的单链线性表
    L = (LinkList) malloc  (sizeof (LNode));
    L -> next = NULL;                                    // 先建立一个带头结点的单链表 
    
    int i = 0;
    for (i = n; i > 0; -- i){
        LinkList p = (LinkList) malloc (sizeof (LNode)); //生成新结点
        printf("please input p -> data, i = %d \n",i);
        // scanf("%d",& (p -> data));                    // 输人元素值，不注释则 vscode 在输入时报错: Unable to perform this action because the process is running.
        p -> data = i;
        p -> next = L -> next; 
        L -> next = p;                                   // 插入到表头
    }
}//CreateList_L
